/* $Header: detector.h,v 2.3 03/06/06 12:16:46 przybyls Exp $ */

/***********************************************************************/
/* INCLUDE FILE NAME:  detector.h                                      */
/* ==================                                                  */
/*                                                                     */
/* Author:  Lesley Freed                                               */
/*                                                                     */
/* Comment: Include file for detector board initialization and         */
/*          miscellaneous functions.                                   */
/*                                                                     */
/***********************************************************************/

#ifndef DET_H
#define DET_H

/*****************************/
/*   IFDEFS                  */
/*****************************/


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/

/*
** hysteresis bounds for TCD filament temperature, per Bob Rhodes (19 Jul 94)
** NOTE:  if these limits are set too small the detector zone will
**    oscillate because of the changing heat from the filament!
*/
#define TCD_FILAMENT_MIN_ON_TEMP    100             /* turn filament on if det is >= this temp */
#define TCD_FILAMENT_MIN_OFF_TEMP   (TCD_FILAMENT_MIN_ON_TEMP - 10) /* turn filament off if det is <= this temp */
#define TCD_FILAMENT_TEMP_TRANSITION    200
#define TCD_FILAMENT_TEMP_LO_THRESHOLD  (TCD_FILAMENT_TEMP_TRANSITION - 5)
#define TCD_FILAMENT_TEMP_HI_THRESHOLD  (TCD_FILAMENT_TEMP_TRANSITION + 5)

#define LDID_PLASMA_ON_HI_THRESHOLD     11*65535/100   /* .110 volts */
#define LDID_PLASMA_ON_LO_THRESHOLD     07*65535/100   /* .070 volts */
#define LDID_PLASMA_SHUTDOWN_THRESHOLD  5*65535/10     /* .5 volts */


/*****************************/
/*   MACROS                  */
/*****************************/


/*****************************/
/*   TYPEDEFS                */
/*****************************/


/*****************************/
/*   FUNCTION PROTOTYPES     */
/*****************************/

/* detector.c */
void InitializeDetectors(void);
void ResetDetConfig(void);
void UpdateDetConfig(void);
void InitializeDetBdMode( POSITION position);
void DetectorPFRecovery(void);
void SetDetDefaultSetpts(const void *p);
void RTTSetFrntTCDNegPolarity(INT32 on_off);
void RTTSetBackTCDNegPolarity(INT32 on_off);
void ResetTCDState(void);
void UpdateDetStatus(void);
void CheckDetConfig(void);
void StartDetStateMachines(void);
void DetPostOffsetMeasurementInit(void);
void DetGasTypeChanged(POSITION p);
void DetGasShutdown(POSITION p, INT8 gas);
INT16 IsDetGasRequired(POSITION p, INT8 gas);
BIT32 GetDetSerialSetpts(void);
void MeasureDetectorOffset(POSITION p);
void EvalDetectorReadiness(U_INT16 tym);
BIT16 GetDetControlSetpts( POSITION p );
void  SetDetControlSetpts( U_INT16 value, POSITION p );

/* det_states.c */
void InitDetectorSubtasks(void);
void InitDetectorSubtask( INT32 i);
void DetectorSubtask(void);
void EvalDetectorStateReadiness(POSITION p, U_INT16 tym);

void FlameIgnite(POSITION p);
void FlameExtinguish(POSITION p);
void FlameShutdown(POSITION p);
ON_OFF FlameStatus(POSITION p);

void TCDOn(POSITION p);
void TCDOff(POSITION p);
void TCDShutdown(POSITION p);
ON_OFF TCDStatus(POSITION p);

void NPDIgnite(POSITION p, int seek);
void NPDExtinguish(POSITION p);
void NPDShutdown(POSITION p);
ON_OFF NPDStatus(POSITION p);

void ECDStartSeek(POSITION p);
void ECDStopSeek(POSITION p);
ON_OFF ECDStatus(POSITION p);

/* npd.c */
void InitNonvolatileNPD(void);
INT32 NPDk (POSITION p, int n);

#endif
